<template>
  <div class="report-form-content">
    <div class="tabs-form-head">
      <span>合同变更</span>
      <div class="">
        <el-button type="primary" plain @click="returnBtn">返回</el-button>
      </div>
    </div>
    <el-divider border-style="dashed" />
    <el-row :gutter="20">
      <el-col :sm="24" :lg="24" style="padding-left: 20px" v-if="objList.length === 0">
        <el-card class="update-log">
          <el-empty :image-size="100" />
        </el-card>
      </el-col>
      <el-col :sm="24" :lg="24" style="padding-left: 20px" v-else>
        <el-card class="update-log">
          <div class="report-form-list-content">
            <div class="report-list">
              <span>合同名称：</span>
              <span>{{ obj.name }}</span>
            </div>
            <div class="report-list">
              <span>签订人：</span>
              <span>{{ showIdLabel(contractSignerList, obj.contractSignerId, 'name') }}</span>
            </div>
            <div class="report-list">
              <span>合同类型：</span>
              <span>{{ showIdLabel(contractTypeList, obj.type, 'name') }}</span>
            </div>
            <div class="report-list">
              <span>负责人：</span>
              <span>{{ showIdLabel(userList, obj.userId, 'name') }}</span>
            </div>
            <div class="report-list">
              <span>合同金额：</span>
              <span>{{ obj.amount }}</span>
            </div>
            <div class="report-list">
              <span>合同起始时间：</span>
              <span>{{ obj.contractLaunch }}</span>
            </div>
            <div class="report-list">
              <span>合同终止时间：</span>
              <span>{{ obj.contractComplete }}</span>
            </div>
          </div>
          <div class="report-form-list-content-1">
            <div class="report-list-a">
              <p>合同内容：</p>
              <p v-html="obj.content"></p>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script setup>
import {getCurrentInstance, ref} from 'vue'
import {doGet} from "@/config/http";
import {svc, showIdLabel, getListPageSize} from "@/config/common";
import { useRoute, useRouter } from 'vue-router'
import initListStore from '@/store/modules/initList'

const router = useRouter()
const route = useRoute()

const { proxy: ctx } = getCurrentInstance();

let obj = ref({
    contractInitialId: route.query.id, // 合同ID
    createBy: '',	// 创建人用户ID
    createTime: '', // 创建时间
    name: '', // 合同名称
    contractSignerId: '', // 签订人
    departmentId: '', // 签订部门
    type: '', // 合同类型
    userId: '', // 负责人
    amount: '', // 合同金额
    contractLaunch: '', // 合同起始时间
    contractComplete: '', // 合同终止时间
    content: '', // 合同内容
    id: '', // 主键ID
  })
let objList = ref([])

let contractTypeList = initListStore().contractTypeList // 合同类型
// let contractCooperationList = ref([]) // 往来单位
// let contractFeetypeList = ref([]) // 合同费用类型
// let contractTemplateList = ref([]) // 合同模版
// let bankList = ref([]) // 银行
let userList = initListStore().userList // 用户
// let governmentList = ref([]) //  政府单位
// let organizationList = ref([]) // 部门
let contractSignerList = initListStore().contractSignerList // 签订人
// let contractFiletypeList = ref([]) // 合同附件类型

// const initList = async () => {
//   let p1 = doGet(svc, '/contract-type/page', {pageSize: getListPageSize()}, false) // 合同类型
//   let p2 = doGet(svc, '/contract-cooperation/page', {pageSize: getListPageSize()}, false) // 往来单位
//   let p3 = doGet(svc, '/contract-feetype/page', {pageSize: getListPageSize()}, false) // 合同费用类型
//   let p4 = doGet(svc, '/contract-template/page', {pageSize: getListPageSize()}, false) // 合同模版
//   let p5 = doGet(svc, '/bank/page', {pageSize: getListPageSize()}, false) // 银行
//   let p6 = doGet(svc, '/user/page', {pageSize: getListPageSize()}, false) // 用户
//   let p7 = doGet(svc, '/government/page', {pageSize: getListPageSize()}, false) //  政府单位
//   let p8 = doGet(svc, '/organization/page', {pageSize: getListPageSize()}, false) // 部门
//   let p9 = doGet(svc, '/contract-signer/page', {pageSize: getListPageSize()}, false) // 签订人
//   let p10 = doGet(svc, '/contract-filetype/page', {pageSize: getListPageSize()}, false) // 合同附件类型

//   let resArray = await Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10])
//   contractTypeList.value = resArray[0]['records']
//   contractCooperationList.value = resArray[1]['records']
//   contractFeetypeList.value = resArray[2]['records']
//   contractTemplateList.value = resArray[3]['records']
//   bankList.value = resArray[4]['records']
//   userList.value = resArray[5]['records']
//   governmentList.value = resArray[6]['records']
//   organizationList.value = resArray[7]['records']
//   contractSignerList.value = resArray[8]['records']
//   contractFiletypeList.value = resArray[9]['records']
// }

const initObj = async () =>  {
  if (route.query.id) {
    objList.value = await doGet(svc, '/contract-initial-change/listByField', {field: 'contractInitialId', values: route.query.id}, true)
    if (objList.value.length > 0) {
      obj.value = objList.value[0]
    }

  }
}
initObj()
// initList()

const returnBtn = () => {
  switch (route.query.kind) {
    case '1':
      ctx.goTargetByName('contractInitial', {});
      break;
    case '2':
      ctx.goTargetByName('contractMain', {})
      break;
  }
}

</script>

<style scoped>
.report-form-content {
  padding: 20px;
}
.update-log {
  width: 100%;
  margin: 30px 0;
}
.report-list {
  width: 31%;
  margin: 15px;
  display: flex;
  align-items: center;
}
.report-list span:nth-child(1) {
  display: inline-block;
  width: 120px;
  text-align: right;
}
.tabs-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tabs-form-head span {
  font-size: 18px;
  color: #303133;
  font-weight: bold;
}
</style>
